package com.cloudm.technician.common.register

import com.cloudm.technician.BaseTestRule
import com.cloudm.technician.data.db.DbHelper
import com.cloudm.technician.data.network.CommonApi
import com.cloudm.technician.data.preferences.PreferencesHelper
import com.cloudm.technician.ui.modules.common.register.RegisterContract
import com.cloudm.technician.ui.modules.common.register.RegisterPresenter
import org.junit.Before
import org.junit.Test
import org.mockito.Mock
import org.mockito.Mockito.verify
import org.mockito.MockitoAnnotations

/**
 * 作者: wesley
 * 时间: 2017/12/19
 * 描述: 注册界面presenter层的单元测试
 */
class RegisterPresenterTest : BaseTestRule() {

    @Mock private lateinit var view: RegisterContract.View

    @Mock private lateinit var commonApi: CommonApi

    @Mock private lateinit var preferencesHelper: PreferencesHelper

    @Mock private lateinit var dbHelper: DbHelper

    private lateinit var presenter: RegisterPresenter

    @Before
    fun setUp() {
        MockitoAnnotations.initMocks(this)
        presenter = RegisterPresenter(view, commonApi, preferencesHelper, dbHelper)
    }

    @Test
    fun testBuildViewByFlagOne() {
        presenter.buildViewByFlag(0)
        verify(view).buildTitleRegister()
        verify(view).setServiceAgreementVisible()
    }

    @Test
    fun testBuildViewByFlagTwo() {
        presenter.buildViewByFlag(1)
        verify(view).buildTitleFindPassword()
        verify(view).setServiceAgreementGone()
    }
}